package com.yida.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.yida.bean.blog;
import com.yida.service.serverblog;

@Controller
public class archived {

	@Autowired
	public serverblog service;
	
	@RequestMapping("/archived")
	public String index(Model mode,Integer page) {
		 Integer pages = 1;
			if (page!=null) {
				pages=page;
			}
	  //按时间排序的博客
	   List<blog> blog= service.selectblog(pages);
	 
	 //热门博客
	  List<blog> blogre = service.selectblogreservice();
	
	 //查询总数
	  Integer pageall = service.selectBlogsSumservice();
	 
	  //查询月份文章数量
	    int[] monthsum = service.selectdateallservice();
	  
	   
	    mode.addAttribute("bloglist", blog);
	    mode.addAttribute("bloglistre", blogre);
	    mode.addAttribute("pages", pageall);
	    mode.addAttribute("cpage", pages);
	    mode.addAttribute("cpage", pages);
	    mode.addAttribute("monthsum", monthsum);
	    
		return "archived";
	}
	
	
}

